************************************************************************
*Stata Dofile for "Faraway, so close: a spatial account of the Conte I *
*government formation in Italy, 2018"								   *
************************************************************************

clear

use "c:\replication\formation opportunities", replace


***government formation models***

clogit realgov doublemaj minwin numparty rangelr, group(formopp)
estimate store m1
predict p1

clogit realgov doublemaj minwin numparty rangelr pec returnability2, group(formopp)
estimate store m2
predict p2

clogit realgov doublemaj minwin numparty rangelr pec returnability2 if /*
*/ majority == 1, group(formopp)
estimate store m3
predict p3 if majority==1

**Table A1**
esttab m1 m2 m3, se aic bic obslast star(+ 0.1 * 0.05 ** 0.01) b(%9.3f) /*
*/ label varwidth(40) replace

*coefficients and conficence intervals for Models 1-3 have been used to
*create Figure 1 (see R code)


***Predictive performance of government formation models***


by formopp: egen maxp1=max(p1)
by formopp: egen maxp2=max(p2)
by formopp: egen maxp3=max(p3)

by formopp: gen realp1=p1 if realgov==1
by formopp: gen realp2=p2 if realgov==1
by formopp: gen realp3=p3 if realgov==1

gen diff1=abs(p1-maxp1)
gen diff2=abs(p2-maxp2)
gen diff3=abs(p3-maxp3)

**data for  Figure 2
list gov diff1 diff2 diff3 if realgov==1

**data for Figure 3
list name p1 p2 p3 if fig3==1

*data on predictive performance have been used to create Figures 2 and 3
*(see R code)
